program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  Summator=class
    N: Integer;
    constructor Create (NewN: integer);

    procedure sum; virtual; abstract;
  end;

  StupidSummator=class(Summator)  
    procedure sum; override;  
  end;

  SmartSummator=class (Summator)
    procedure sum; override;
  end;
var
  s: Summator;
  NewN: integer;
{ StupidSummator }

procedure StupidSummator.sum;
var
  i, s: integer;
begin
  s:=0;
  for i:=1 to N do
    s:=s+i;
  writeln('stupidsummator:', s);

end;

{ SmartSummator }

procedure SmartSummator.sum;
begin
  writeln('SmartSummator:', (N*(N+1) div 2));

end;

{ Summator }

constructor Summator.Create(NewN: integer);
begin
  N:=NewN;
end;

begin
  readln(NewN);
  s:=StupidSummator.Create(NewN);
  s.sum;
  s:=smartsummator.create(NewN);
  s.sum;
  readln;
end.
 